package com.yh.yh_listview;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class activity extends AppCompatActivity {
    private String[] weekStrings={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_activity);
        ArrayAdapter<String>adapter=new ArrayAdapter<String>(
                activity.this, android.R.layout.simple_list_item_1, weekStrings
        );
        ListView listView=(ListView) findViewById(R.id.listview);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                activity.this.setTitle(((TextView) view). getText());
            }
        });
    }
}
